package(default_visibility = ["//visibility:public"])

load("//tools:sass_bundle.bzl", "sass_bundle")
load("//tools:defaults.bzl", "ng_module", "ng_package")
load(
    "//:packages.bzl",
    "MATERIAL_PACKAGES",
    "MATERIAL_SCSS_LIBS",
    "MATERIAL_TARGETS",
    "ROLLUP_GLOBALS",
)

# Root "@angular/material" entry-point.
ng_module(
    name = "material",
    srcs = glob(
        ["*.ts"],
        exclude = ["**/*.spec.ts"],
    ),
    module_name = "@angular/material",
    deps = ["//src/material/%s" % p for p in MATERIAL_PACKAGES] + [
        "@npm//@angular/forms",
        "@npm//@angular/animations",
    ],
)

sass_bundle(
    name = "theming_bundle",
    srcs = [
        "//src/cdk/a11y:a11y_scss_lib",
        "//src/cdk/overlay:overlay_scss_lib",
        "//src/cdk/text-field:text_field_scss_lib",
    ] + MATERIAL_SCSS_LIBS,
    entry_point = "//src/material/core:theming/_all-theme.scss",
    output_name = "_theming.scss",
)

filegroup(
    name = "overviews",
    srcs = ["//src/material/%s:overview" % name for name in MATERIAL_PACKAGES],
)

# Creates the @angular/material package published to npm.
ng_package(
    name = "npm_package",
    srcs = ["package.json"],
    data = [
        ":theming_bundle",
        "//src/material/prebuilt-themes:deeppurple-amber",
        "//src/material/prebuilt-themes:indigo-pink",
        "//src/material/prebuilt-themes:pink-bluegrey",
        "//src/material/prebuilt-themes:purple-green",
    ],
    entry_point = "src/material/public_api.js",
    entry_point_name = "material",
    globals = ROLLUP_GLOBALS,
    packages = ["//src/material/schematics:npm_package"],
    # TODO(devversion): Use the npm package for publishing. Right now this is disabled because
    # we build using AOT for serving & testing, but the `ng_package` rule should not include factory
    # files.
    tags = ["manual"],
    deps = MATERIAL_TARGETS,
)
